package com.lhf.warnsend.warnsendjson.dao;

import com.lhf.warnsend.warnsendjson.entity.UseAlarmMsg;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

/**
 * (UseAlarmMsg)表数据库访问层
 *
 * @author liuhf
 * @since 2021-09-02 16:08:43
 */
public interface UseAlarmMsgDao  {


    /**
     * 查询为发送短信的数据
     *
     * @return
     */
    @Select("select * from USE_ALARM_MSG t where  t.DEAL_TIME IS NULL")
    List<UseAlarmMsg> findUnSend();


    /**
     * 标识已发送短信的数据
     *
     * @return
     */
    @Update("update USE_ALARM_MSG set DEAL_TIME=TO_TIMESTAMP(#{alarmMsg.dealTime}, 'YYYY-MM-DD HH24:MI:SS.FF6') where ALARM_MODE = #{alarmMsg.alarmMode} and TARGET_DATA LIKE  #{alarmMsg.targetData} ESCAPE '#' and ALARM_TIME = TO_TIMESTAMP(#{alarmMsg.alarmTime} , 'YYYY-MM-DD HH24:MI:SS.FF6')\n")
    int modifySent(@Param("alarmMsg") UseAlarmMsg alarmMsg);
}
